package message.pojo;

import lodsve.core.utils.DateUtils;
import lodsve.search.bean.BaseSearchBean;

import java.util.Date;

/**
 * .
 *
 * @author sunhao(sunhao.java@gmail.com)
 * @version V1.0, 14-9-14 下午4:01
 */
public class DemoSearchBean extends BaseSearchBean {
    @Override
    public String[] getDoSearchFields() {
        return new String[]{"content"};
    }

    @Override
    public String[] getDoIndexFields() {
        return new String[]{"name", "content"};
    }

    @Override
    public void initPublicFields() throws Exception {
        Object obj = super.getObject();
        Demo demo = null;
        if (obj instanceof Demo) {
            demo = (Demo) obj;
        }

        if (demo == null) {
            return;
        }

        Long pkId = demo.getPkId();
        super.setId(pkId.toString());
        super.setOwerId("1");
        super.setOwerName("孙昊");
        super.setLink("http://www.baidu.com");
        super.setKeyword("一个demo,id为" + pkId + ",name为" + demo.getName());
        super.setCreateDate(DateUtils.formatDate(new Date(), DateUtils.DEFAULT_PATTERN));
    }

    @Override
    public String getIndexType() {
        return this.getClass().getSimpleName();
    }
}
